import { CommonPage, forgotPassType, LoginForm, RegisterForm, updateEmailType, updatePassType } from "@/types/userTypes"
import request from "@/utils/request"
import qs from 'qs'

// 登录
export const loginApi = (params: LoginForm) => {
  return request.post(`/api/nest/user/login`, qs.stringify(params))
}

// 手机号登录
export const phoneLoginApi = (params: LoginForm) => {
  return request.post(`/api/nest/user/phone/login`, qs.stringify(params))
}

// 注册
export const registerApi = (params: RegisterForm) => {
  return request.post(`/api/nest/user/register`, qs.stringify(params))
}

// 手机号注册
export const phoneRegisterApi = (params: RegisterForm) => {
  return request.post(`/api/nest/user/phone/register`, qs.stringify(params))
}

// 留言list
export const commentList = (params: { user_id: number } & CommonPage) => {
  return request.post(`/api/nest/user/comment/list`, qs.stringify(params))
}

// 留言保存
export const commentSave = (params: { name: string }) => {
  return request.post(`/api/nest/user/comment/save`, qs.stringify(params))
}

// 用户信息
export const profileInfo = () => {
  return request.post(`/api/nest/user/profile/info`)
}

// 用户信息修改
export const profileModify = (params: { nickname: string }) => {
  return request.post(`/api/nest/user/profile/modify`, qs.stringify(params))
}

// 修改密码
export const changePass = (params: updatePassType) => {
  return request.post(`/api/nest/user/profile/changePass`, qs.stringify(params))
}

// 更改头像
export const avatarModify = (params: { avatar: string }) => {
  return request.post(`/api/nest/user/profile/avatar`, qs.stringify(params))
}

// 数据信息统计
export const userStat = () => {
  return request.post(`/api/nest/user/stat`)
}

// 签到
export const checkin = () => {
  return request.post(`/api/nest/user/checkin`)
}

// 签到统计
export const checkinStat = () => {
  return request.post(`/api/nest/user/checkin/stat`)
}

// 账户明细
export const walletLogList = (params: CommonPage) => {
  return request.post(`/api/nest/user/wallet/logs/list`, qs.stringify(params))
}

// 修改邮箱
export const updateEmail = (params: updateEmailType) => {
  return request.post(`/api/nest/user/profile/updateEmail`, qs.stringify(params))
}

// 重置密码
export const forgotPass = (params: forgotPassType) => {
  return request.post(`/api/nest/user/profile/forgetPass`, qs.stringify(params))
}

// 退出登录
export const logoutApi = () => {
  return request.post(`/api/nest/user/logout`)
}